<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>iArchie博客</legend>
</fieldset>
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">博客新增</div>
                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <label class="layui-form-label">文章标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入文章标题"
                                   class="layui-input">
                        </div>
                    </div>
                    <!--橙色分割线-->
                    <hr class="layui-bg-orange">
                    <div class="layui-form-item">
                        <label class="layui-form-label">文章分类名</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入文章分类名"
                                   class="layui-input">
                        </div>
                    </div>
                    <!--蓝色分割线-->
                    <hr class="layui-bg-blue">
                    <!--存放内容-->
                    <textarea class="layui-textarea" id="LAY_demo1" style="display: none">
                       请输入文章主体内容。。。。
                    </textarea>
                    <div class="site-demo-button" style="margin-top: 20px;">
                        <button class="layui-btn site-demo-layedit" data-type="content">获取编辑器内容</button>
                        <button class="layui-btn site-demo-layedit" data-type="text">获取编辑器纯文本内容</button>
                        <button class="layui-btn site-demo-layedit" data-type="selection">获取编辑器选中内容</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../layui/layui.js"></script>
<script>
    layui.use('layedit', function () {
        var layedit = layui.layedit
            , $ = layui.jquery;
        //构建一个默认的编辑器
        var index = layedit.build('LAY_demo1');

        //编辑器外部操作
        var active = {
            content: function () {
                alert(layedit.getContent(index)); //获取编辑器内容
            }
            , text: function () {
                alert(layedit.getText(index)); //获取编辑器纯文本内容
            }
            , selection: function () {
                alert(layedit.getSelection(index));
            }
        };

        $('.site-demo-layedit').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>
</body>
</html>